class kmeans
{
  public:
    
    
    inline 		kmeans(const mat &in_data, const uword in_Ncent);
    inline void 	run(const uword N_iter);
    
    
    inline mat get_means();
    inline field<mat> get_covs();
    inline vec get_weights();
    
    
    
  private:
    
    
    const mat& 		data;
    const uword 	N_cent;
    const uword		Dim;
    const uword		N_data;
    
    umat partitions;
    umat partitions2; // 

    mat cent_1;
    mat cent_2;
    vec distances;
    uvec counts;
    uvec counts2;

    double err;
    uword best_ci;
    mat means;
    vec weights;
    
    inline void 	ini_cent();
    inline void		ini_cent(const uword Nc, ucolvec indices);
    inline void 	update_cent();
    inline void		update_cent(ucolvec index);
    inline void 	check_cent();
};
